<div>
	<div class="header">
		<a href="#parterpage" class="btn btnleft">返回</a>
		<h1>{{headerName}}</h1>
	</div>
	<div class="content nobottom">
		<div class="padding-top-sm" style="padding:6px;overflow-x:hidden;">
			<form class="form-horizontal" id="createform{{identify}}" role="form">
				<div class="form-group">
					<label class="col-sm-4 control-label"><span class="required">#</span>产品名称</label>
					<div class="col-sm-8">
						<input type="text" id="productproductName{{identify}}" name="product.productName" class="form-control" placeholder="产品名称" maxlength="20">
					</div>
				</div>
				<div class="form-group">
					<label class="col-sm-4 control-label"><span class="required">#</span>产品类型</label>
					<div class="col-sm-8">
						<select name="product.productType" class="form-control">
	    					<option value="0">冻品</option>
	    					<option value="1">干货</option>
	    					<option value="2">活鲜</option>
	    					<option value="3">水果</option>
	    					<option value="4">调料</option>
						</select>
					</div>
				</div>
				<div class="form-group">
					<label class="col-sm-4 control-label"><span class="required">#</span>产品产地</label>
					<div class="col-sm-8">
						<input type="text" id="productproductAddress{{identify}}" name="product.productAddress" class="form-control" placeholder="产品产地" maxlength="20">
					</div>
				</div>
				<div class="form-group">
					<label class="col-sm-4 control-label"><span class="required">#</span>产品属地</label>
					<div class="col-sm-8">
						<input type="text" id="productproductLocation{{identify}}" name="product.productLocation" class="form-control" placeholder="产品属地" maxlength="20">
					</div>
				</div>
				<div class="form-group">
					<label class="col-sm-4 control-label"><span class="required">#</span>产品价格</label>
					<div class="col-sm-8">
						<input type="text" id="productproductPrice{{identify}}" name="product.productPrice" class="form-control" placeholder="产品价格" maxlength="10">
					</div>
				</div>
				<div class="form-group">
					<label class="col-sm-4 control-label"><span class="required">#</span>产品数量</label>
					<div class="col-sm-8">
						<input type="text" id="productproductNum{{identify}}" name="product.productNum" class="form-control" placeholder="产品数量" maxlength="10">
					</div>
				</div>
				<div class="form-group">
					<label class="col-sm-4 control-label">产品描述</label>
					<div class="col-sm-8">
						<textarea name="product.productDesc" class="form-control" rows="2" id="scripttemp" placeholder="产品描述"></textarea>
					</div>
				</div>
				<div class="imagebuttondiv form-group">
					<div class="col-sm-12">
						<div style="width:0px;height:0px;overflow:hidden;">
							<input type="file" name="file" id="uploadImageFileProduct{{identify}}" accept="image/*;capture=camera" value=""/>
						</div>
						<button type="button" id="imagechoise{{identify}}" class="btn btn-default btn-lg btn-block">选择图片</button>
					</div>
				</div>
				<div class="form-group">
					<div class="col-sm-12">
						<button type="submit" id="submit{{identify}}" class="btn btn-default btn-lg btn-block">确认发布</button>
					</div>
				</div>
			</form>
		</div>
	</div>
	<script type="text/javascript">
	$(document).ready(function() {
		$('#imagechoise{{identify}}').on('click', function(e) {
			e.preventDefault();
			var length = $('#createform{{identify}}').find('canvas').length;
			if (length >= 3) {
				Global.longToast('最多只能选择三张图片!');
				return;
			}
			if (Global.isIphone()) {
				$('#uploadImageFileProduct{{identify}}').show().focus().click().hide();//ios
			} else {
				$('#uploadImageFileProduct{{identify}}').click();
			}
		});
		$('#uploadImageFileProduct{{identify}}').bind('change', function(e) {
			var object = e.target;
			window.setTimeout(function() {
				PageTools.triggerFileInputTag(object, {
					imgId: new Date().getTime(),
					insertSelector: 'div.imagebuttondiv',
					removeCallback: function() {
						$('#uploadImageFileProduct{{identify}}').val('');
					}
				});
	        }, 0);
		});
		$('#submit{{identify}}').on('click', function(e) {
			var $this = $(this);
			$this.attr('disabled', 'disabled');
			var canvas = $('#createform{{identify}}').find('canvas');
			var length = canvas.length;
			if (length == 0) {
				Global.longToast('请选择至少一张图片!');
				$this.removeAttr('disabled');
				return;
			}
			var v = [{
				id: 'productproductName{{identify}}',
				msg: '请输入产品名称'
			},{
				id: 'productproductAddress{{identify}}',
				msg: '请输入产品产地'
			},{
				id: 'productproductLocation{{identify}}',
				msg: '请输入产品属地'
			},{
				id: 'productproductPrice{{identify}}',
				msg: '请输入产品价格'
			},{
				id: 'productproductNum{{identify}}',
				msg: '请输入产品数量'
			}];
			var vmsg = [];
			for (var i = 0; i < v.length; i++) {
				var vi = v[i];
				if ('' == $.trim($('#' + vi.id).val())) {
					vmsg[i] = vi.msg;
				}
			}
			if (vmsg.length > 0) {
				Global.longToast(vmsg.join(','));
				$this.removeAttr('disabled');
				return;
			}
			Global.loading();
			$('.canvasdataurl').remove();//移除已经存在的元素
			var form = $('#createform{{identify}}');
			canvas.each(function() {
				form.append(['<input type="hidden" class="canvasdataurl" name="images" value="', this.toDataURL(), '">'].join(''));
			});
			console.log($('#createform{{identify}}').serialize());
			$this.removeAttr('disabled');
			Global.loaded();
		});
	});
	<{{!}}/script>
</div>